package com.robot.member.controller;

import com.alibaba.fastjson.JSON;
import com.robot.member.pojo.CartDetails;
import com.robot.member.service.CartDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author wuyunbin
 */
@RestController
@CrossOrigin
@RequestMapping("/details")
public class CartDetailsJsonController {
    @Autowired
    private CartDetailsService cartDetailsService;

    /**
     * 通过cartId 获取详细类目
     *
     * @param cartId
     * @return
     */
    @RequestMapping(value = "third/findByCartId/{cartId}", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String thirdFindByCartId(@PathVariable String cartId) {
        List<CartDetails> cartDetailsList = cartDetailsService.findAllByCartIdAndDeletedAtIsNull(cartId);
        return JSON.toJSONString(cartDetailsList);
    }
}
